package code15.f;

import java.io.File;

public class Homework01 {

	public static void main(String[] args) {
		//printChilds("src");
		printOffspring("src");
	}
	
	/**
	 * 输出该目录下的 子文件(普通文件、目录)的名称
	 * @param pathname
	 */
	public static void printChilds(String pathname){
		File f = new File(pathname);
		if (!f.isDirectory()) {
			throw new IllegalArgumentException("不是一个有效目录");
		}
		String[] list = f.list();
		for (String fileName : list) {
			System.out.println(fileName);
		}
	}
	/**
	 * 输出该目录下的所有文件的绝对路径
	 * @param pathname
	 */
	public static void printOffspring(String pathname){
		// 递归
		File f = new File(pathname);
		System.out.println(f.getAbsolutePath());
		if (f.isDirectory()) {
			File[] listFiles = f.listFiles();
			for (File file : listFiles) {
				printOffspring(file.getAbsolutePath());
			}
		}
	}
}
